<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/batter.css">
</head>

<body>
    <div class="batter-in">
        <div class="yangyuanzhang">
            <img src="../img/yangyuanzhang.png" alt="">

            <div class="gongji">
                <button>周波</button>
                <button>哈基米</button>
                <button>释放武器特效</button>
            </div>


        </div>
        <div class="">
            <div class="zhoubo">
                <img src="../img/zhoubo.png" alt="">
            </div>
            <div class="hajimi">

            </div>

        </div>

    </div>





    <script>
        let yangyuanzhang = {
            name: '杨院长',
            hp: 1000,
            mp: 500,
            gongjili: 300,
            fangyuli: 50,
            sudu: 30,
            status: 1,
            wuqi1: 0,
            wuqi2: 0,
            wuqi3: 0,
            gongji(name) {
                alert(`${this.name}对${name.name}发动了攻击，造成了${this.gongjili - name.fangyuli}点伤害`)
                name.hp -= this.gongjili - name.fangyuli
                if (name.hp <= 0) {
                    name.status = 0
                    alert(`${name.name}死亡`)
                } else {
                    alert(`${name.name}剩余血量为${name.hp}`)
                }
            },
            chuanzhuangbei(name) {
                if (name.gongjili == 50) {
                    this.wuqi1 = 1;
                    alert(`${this.name}穿上了${name.name}`)
                    alert(`${name.desc}`)
                    this.gongjili += name.gongjili
                    alert(`${this.name}的攻击力提升了`)
                } else
                    if (name.gongjili == 100) {
                        this.wuqi2 = 1;
                        alert(`${this.name}穿上了${name.name}`)
                        alert(`${name.desc}`)
                        this.gongjili += name.gongjili
                        alert(`${this.name}的攻击力提升了`)
                    } else
                        if (name.gongjili == 400 && yangyuanzhang.wuqi1 == 1 && yangyuanzhang.wuqi2 == 1) {
                            this.wuqi3 = 1;
                            this.wuqi1 = 0;
                            this.wuqi2 = 0;
                            alert(`${this.name}穿上了${name.name}`)
                            alert(`${name.desc}`)
                            this.gongjili += 250;
                            alert(`${this.name}的攻击力提升了`)
                        } else {
                            alert('杨院长不知道什么是电学圣剑')
                        }
            },
            shiyongwuping(name) {
                alert(`${this.name}使用了${name.name},回复了${name.hp}点血量`)
                this.hp += name.hp
            },
            taopao(zhandou) {
                alert(`生为杨院长怎么能逃跑呢，滚回去战斗`)
                yangyuanzhanggongji();
            }
        };
        let zhoubo = {
            name: '周波',
            hp: 500,
            mp: 100,
            gongjili: 0,
            fangyuli: 0,
            sudu: 25,
            status: 1,
            gongji(num, name) {
                if (num == 1) {
                    alert(`${this.name}对${name.name}使用了普通攻击，造成${this.gongjili}点伤害`)
                } else {
                    if (this.mp >= 100) {
                        alert(`${this.name}对${name.name}使用了喵喵叫,消耗100点mp,造成200点伤害`)
                        name.hp -= 200;
                        this.mp -= 100;
                        if (name.hp <= 0) {
                            name.status = 0
                            alert(`${name.name}死亡`)
                        } else {
                            alert(`${name.name}剩余血量为${name.hp}`)
                        }
                    } else {
                        alert(`${this.name}的mp不足，释放失败`)
                        this.gongji(1, name)
                    }

                }
            }
        }
        let hajimi = {
            name: '哈基米',
            hp: 700,
            mp: 30,
            gongjili: 100,
            fangyuli: 100,
            sudu: 50,
            status: 1,
            gongji(num, name) {
                if (num == 1) {
                    alert(`${this.name}对${name.name}使用了普通攻击，造成${this.gongjili - name.fangyuli}点伤害`)
                    name.hp -= this.gongjili - name.fangyuli
                    if (name.hp <= 0) {
                        name.status = 0
                        alert(`${name.name}死亡`)
                    } else {
                        alert(`${name.name}剩余血量为${name.hp}`)
                    }
                } else {
                    if (this.mp >= 10) {
                        alert(`${this.name}对${name.name}使用了撕咬,消耗10点mp,造成100点伤害`)
                        name.hp -= 100;
                        this.mp -= 10;
                        if (name.hp <= 0) {
                            name.status = 0
                            alert(`${name.name}死亡`)
                        } else {
                            alert(`${name.name}剩余血量为${name.hp}`)
                        }
                    } else {
                        alert(`${this.name}的mp不足，释放失败`)
                        this.gongji(1, name)
                    }
                }
            }
        }
        let wuqi = {
            wuqi1: {
                name: '电棒',
                desc: '杨院长用电蚊拍改造的电棒，对哈基米的伤害不够，只能用来电电蚊子',
                gongjili: 50,
            },
            wuqi2: {
                name: '戒尺',
                desc: '杨院长在跳蚤市场淘来的戒尺，金属制品,对哈基米有恐吓效果',
                gongjili: 100,
                texiao() {
                    alert(`对哈基米和周波造成了恐惧效果,速度减少10点`)
                    hajimi.sudu -= 10
                    zhoubo.sudu -= 10
                }
            },
            wuqi3: {
                shiyongzhe: null,
                name: '电学圣剑',
                desc: '杨院长用电棒和戒尺组合而成的电学圣剑,无敌',
                gongjili: 400,
                texiao(name1, name2) {
                    if (name1 == name2) {
                        alert(`对${name1.name}攻击2次，造成${(yangyuanzhang.gongjili - name1.fangyuli) * 2 - 50}点伤害`)
                        name1.hp -= (yangyuanzhang.gongjili - name1.fangyuli) * 2 - 50
                        if (name1.hp <= 0) {
                            name1.status = 0
                            alert(`${name1.name}死亡`)
                        } else {
                            alert(`${name1.name}剩余血量为${name1.hp}`)
                        }
                    }
                    else {
                        alert(`对${name1.name}和${name2.name}发动攻击，分别造成${yangyuanzhang.gongjili - name1.fangyuli}点伤害和${yangyuanzhang.gongjili - name2.fangyuli}点伤害`)
                        name1.hp -= yangyuanzhang.gongjili - name1.fangyuli
                        name2.hp -= yangyuanzhang.gongjili - name2.fangyuli
                        if (name1.hp <= 0) {
                            name1.status = 0
                            alert(`${name1.name}死亡`)
                        } else {
                            alert(`${name1.name}剩余血量为${name1.hp}`)
                        }
                        if (name2.hp <= 0) {
                            name2.status = 0
                            alert(`${name2.name}死亡`)
                        } else {
                            alert(`${name2.name}剩余血量为${name2.hp}`)
                        }
                    }
                }
            }
        }
        let wuping = {
            xuebao: {
                name: '芝士雪豹',
                hp: 500
            },
            ruike: {
                name: '锐克5代',
                hp: 1000
            }
        }
        let yangyuanzhangChuji = 0;
        let zhouboChuji = 0;
        let hajimiChui = 0;

        function yangyuanzhanggongji() {
            let a = prompt(`请选择攻击目标：1、哈基米 2、周波 3、释放武器特效`)


            switch (Number(a)) {
                case 1: yangyuanzhang.gongji(hajimi)
                    break;
                case 2: yangyuanzhang.gongji(zhoubo)
                    break;
                case 3:
                    if (yangyuanzhang.wuqi1 == null && yangyuanzhang.wuqi2 == null && yangyuanzhang.wuqi3 == null) {
                        alert('杨院长还没装备武器')
                        yangyuanzhanggongji()
                    } else {
                        let a = prompt('请输入要释放的武器特效：1、电棒 2、戒尺 3、电学圣剑')
                        switch (Number(a)) {
                            case 1:
                                if (yangyuanzhang.wuqi1 == 0) {
                                    alert('杨院长未装备电棍')
                                } else {
                                    alert('杨院长捣鼓了一阵电棒，什么也没发生')
                                }
                                break;
                            case 2:
                                if (yangyuanzhang.wuqi2 == 0) {
                                    alert('杨院长未装备戒尺')
                                } else {
                                    wuqi.wuqi2.texiao()
                                }
                                break;
                            case 3:
                                if (yangyuanzhang.wuqi3 == 0) {
                                    alert('杨院长未装备电学圣剑')
                                } else {
                                    let a = prompt('请输入第一次攻击的对象1、哈基米 2、周波')
                                    let b = prompt('请输入第二次攻击的对象1、哈基米 2、周波')

                                    if (a == 1 && b == 1)
                                        wuqi.wuqi3.texiao(hajimi, hajimi)
                                    else if (a == 2 && b == 2) {
                                        wuqi.wuqi3.texiao(zhoubo, zhoubo)
                                    } else if (a == 1 && b == 2) {
                                        wuqi.wuqi3.texiao(hajimi, zhoubo)
                                    } else if (a == 2 && b == 1) {
                                        wuqi.wuqi3.texiao(zhoubo, hajimi)
                                    } else (
                                        alert('输入错误，杨院长不知道怎么操作')
                                    )
                                }
                                break;

                        }
                    }
                    break;
                default:
                    alert('输入错误，请重新输入')
                    yangyuanzhanggongji()
                    break;
            }
        }
        function yangyuanzhangchuanzhuangbei() {
            let a = prompt('请输入要穿上的装备:1、电棒 2、戒尺 3、电学圣剑')
            switch (Number(a)) {
                case 1: yangyuanzhang.chuanzhuangbei(wuqi.wuqi1)
                    break;
                case 2: yangyuanzhang.chuanzhuangbei(wuqi.wuqi2)
                    break;
                case 3: yangyuanzhang.chuanzhuangbei(wuqi.wuqi3)
                    break;
                default:
                    alert('输入错误，请重新输入');
                    yangyuanzhangchuanzhuangbei();
                    break;

            }
        }
        function yangyuanzhanshiyongwuping() {
            let a = prompt('请输入要使用的物品：1、芝士雪豹 2、锐克五代')
            if (a == 1) {
                yangyuanzhang.shiyongwuping(wuping.xuebao)
            } else
                if (a == 2) {
                    yangyuanzhang.shiyongwuping(wuping.ruike)
                } else {
                    alert('输入错误，请重新输入')
                    yangyuanzhanshiyongwuping()
                }
        }
        alert('杨院长在陪伴好兄弟闲逛的时候发现了一只哈基米')
        alert('杨院长本着戒网瘾精神，想摸摸哈基米的爪子')
        alert('哈基米被激怒了，对杨院长发起了攻击')
        alert('杨院长的好兄弟哈基米·周也对杨院长发起了攻击')
        while (1 > 0) {
            yangyuanzhangChuji += yangyuanzhang.sudu;
            if (yangyuanzhangChuji >= 100) {
                yangyuanzhangChuji -= 100;
                alert(`到杨院长的回合了，请选择操作`)
                let a = prompt(`1、攻击 2、穿装备 3、使用物品 4、逃跑`)
                switch (Number(a)) {
                    case 1: yangyuanzhanggongji()
                        break;
                    case 2: yangyuanzhangchuanzhuangbei()
                        break;
                    case 3: yangyuanzhanshiyongwuping()
                        break;
                    case 4: yangyuanzhang.taopao()
                        break;
                }
            }
            zhouboChuji += zhoubo.sudu;
            if (zhouboChuji >= 100 && zhoubo.status == 1) {
                zhouboChuji -= 100;
                alert('到周波的回合了')
                zhoubo.gongji(prompt('请输入周波的攻击方式：1、普通攻击 2、释放技能'), yangyuanzhang)
            }
            hajimiChui += hajimi.sudu;
            if (hajimiChui >= 100 && hajimi.status == 1) {
                hajimiChui -= 100;
                alert('到哈基米的回合了')
                hajimi.gongji(prompt('请输入哈基米的攻击方式：1、普通攻击 2、释放技能'), yangyuanzhang)
            }
            if (yangyuanzhang.status == 0) {
                alert('杨院长死亡，菜就多练')
                break;
            }
            if (zhoubo.status == 0 && hajimi.status == 0) {
                alert('周波和哈基米死亡,游戏胜利')
                break;
            }
        }


    </script>

</body>

</html>